﻿$(document).ready(function () {
	//var smuser = new SmUser();
	//smuser.GetCurrentUser();
    
    var obj = new SmObjectData("CLDJS_CM");
    obj.Init("BSM","28c11551-c4a7-4fc0-b214-b0c278b08481");

	var smcb01 = new SmCB();
	$("#xzqtree").combotree('loadData', smcb01.GetXZQTree('540000'));
	$('#xzqtree').combotree('setValue', 540000);
	$("#xzqtree2").combotree('loadData', smcb01.GetXZQTree('371700'));
	$('#xzqtree2').combotree('setValue', 371700);
	$("#xzqtree3").combotree('loadData', smcb01.GetXZQTree('341723'));
	$('#xzqtree3').combotree('setValue', 341723);

	$("#gtcb01").combobox('loadData', smcb01.InitCB01('10000'));
	$("#gtcb02").combobox('loadData', smcb01.InitCB02('83750'));
	$("#gtcb03").combobox('loadData', smcb01.InitCB03('83907'));
	$("#gtcb05").combobox('loadData', smcb01.InitCB05());
	$("#kctree").combotree('loadData', smcb01.GetKCDMTree());
	$("#gtcb09").combobox('loadData', smcb01.InitCB09());
	$("#gtcb13").combobox('loadData', smcb01.InitCB13());
	$('#gtcb13').combobox('setValue', '111b');
    //资源储量grid
	var zycldata = new SmDataTable();

	zycldata.GetZYCL("28c11551-c4a7-4fc0-b214-b0c278b08481");
	$('#zyclgrid').datagrid({
	    title: '资源储量', //列表的标题       
	    iconCls: 'icon-ok',
	    width: 'auto',
	    height: '300',
	    nowrap: false,
	    striped: true,
	    collapsible: true,
	    singleSelect: true,
	    columns: [[
        {
            field: 'KCMC', title: '矿产名称及组合',align:'center',
            formatter: function (value, row, index) {
                return value.replace("^", "<br/>--------<br/>");
            },
            styler: function (value, row, index) {
                return 'vertical-align:middle;';
            }
        },
        {
            field: 'TJDX', title: '统计对象及资源储量单位', align: 'center',
            formatter: function (value, row, index) {
                return value.replace("^", "<br/>--------<br/>");
            },
            styler: function (value, row, index) {
                return 'vertical-align:middle;';
            }
        },
        {
            field: 'KSLX', title: '矿石类型及品级', align: 'left',
            formatter: function (value, row, index) {
                return value.replace("|", "<br/>");
            },
            styler: function (value, row, index) {
                return 'vertical-align:left;';
            }
        },
        {
            field: 'ZFHL', title: '矿石主要组分及质量指标', align: 'center',
            formatter: function (value, row, index) {
                return value.replace("|", "<br/>");
            },
            styler: function (value, row, index) {
                return 'vertical-align:middle;';
            }
        },
        { field: 'CLLX', title: '资源储量类型', align: 'center' },
        {
            field: 'BYCL', title: '保有储量', align: 'center',
            formatter: function (value, row, index) {
                return value.replace("^", "<br/>--------<br/>");
            },
            styler: function (value, row, index) {
                return 'vertical-align:middle;';
            }
        },
        {
            field: 'LJCL', title: '累计储量', align: 'center',
            formatter: function (value, row, index) {
                return value.replace("^", "<br/>--------<br/>");
            },
            styler: function (value, row, index) {
                return 'vertical-align:middle;';
            }
        }
	    ]]
	});

	$('#zyclgrid').datagrid("loadData", zycldata.GetEasyuiGridData());
	$('#zyclgrid').datagrid('mergeCells', { index: 0, field: 'KCMC', rowspan: 3, colspan: 1 });
	$('#zyclgrid').datagrid('mergeCells', { index: 0, field: 'TJDX', rowspan: 3, colspan: 1 });
	$('#zyclgrid').datagrid('mergeCells', { index: 0, field: 'KSLX', rowspan: 3, colspan: 1 });
	$('#zyclgrid').datagrid('mergeCells', { index: 0, field: 'ZFHL', rowspan: 3, colspan: 1 });
    //简单grid
	var spdata = new SmDataTable();
	spdata.Init("select BSM,NAME,URL from sys_menu");
	$('#simplegrid').datagrid({
	    title: '系统菜单项配置', //列表的标题       
	    iconCls: 'icon-ok',
	    width: 'auto',
	    height: '200',
	    nowrap: false,
	    striped: true,
	    collapsible: true,
	    singleSelect: true,
	    sortName: 'BSM',
	    sortOrder: 'asc',
	    idField: 'BSM',
	    columns: [[
        { field: 'BSM', title: '编码' },
        { field: 'NAME', title: '菜单项' },
        { field: 'URL', title: '访问地址' }
	    ]]
	});
	$('#simplegrid').datagrid("loadData", spdata.GetEasyuiGridData());
	$('#simplegrid').datagrid('mergeCells', {index:4,field:'URL',rowspan:2,colspan:1});

    //treegrid
	$('#treegrid').treegrid({
	    idField: 'BSM',
	    treeField: 'NAME',
	    columns: [[
            { field: 'NAME', title: '菜单项', width: 180 },
            { field: 'URL', title: '访问地址', width: 160},
            { field: 'ICON', title: '图标', width: 80 },
            { field: 'BZ', title: '备注', width: 80 },
            { field: 'XH', title: '显示序号', width: 80 }
	    ]]
	});
	//$('#treegrid').treegrid('loadData', "");
	GetSmJSON(CLDJServiceUrl + "/SmwsFrame.asmx/GetMenuTreeGrid", "{}", function (d) {
	    if (d != "") {
	        $('#treegrid').treegrid('loadData', JSON.parse(d));
	    }
	});

    
});